package com.dosin.crowno;

import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.Mnemonic;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;



@EnableAsync
@EnableScheduling
@SpringBootApplication
public class CrownoApplication extends javafx.application.Application {


    private static ApplicationContext applicationContext;


    //将fxml文件导入到Springboot
    public static FXMLLoader loadFxml(String fxmlPath){
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(CrownoApplication.class.getResource(fxmlPath));
        fxmlLoader.setControllerFactory(applicationContext::getBean);

        return fxmlLoader;
    }


    @FXML
    private Button loginButton;

    public static void main(String[] args) {

        applicationContext = SpringApplication.run(CrownoApplication.class, args);
        Application.launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

           // Scene scene = new Scene(loadFxml("/login.fxml").load());
        //primaryStage.setTitle("欢迎您登录金皇冠系统");
        primaryStage.setScene(new Scene(loadFxml("/login.fxml").load()));
        //primaryStage.setScene(scene);
        primaryStage.initStyle(StageStyle.UNDECORATED);
        primaryStage.show();



    }
}
